package com.nettest.util;

import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;


public class ConvertUtil {
	
	public static String number2Str(Number number, String format) {
		NumberFormat formater = new DecimalFormat(format);
		return formater.format(number);
	}
	
	public static String date2Str(Date date, String format) {
		SimpleDateFormat formater = new SimpleDateFormat(format);
		return formater.format(date);
	}

	public static Date str2Date(String dateStr, String format) {
		SimpleDateFormat formater = new SimpleDateFormat(format);
		Date parse;
		try {
			parse = formater.parse(dateStr);
		} catch (ParseException e) {
			parse = new Date();
		}
		
		return parse;
	}
	public static String date2Str(java.sql.Timestamp date, String format) {
		return null;
	}

	public static String date2Str(java.sql.Date date, String format) {
		return null;
	}
	
}
